/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;

/**
 * <p>Project: jse2302 - HashSetDemo
 * <p>Powered by webrx On 2023-06-25 14:41:21
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class HashSetDemo {
    public static void main(String[] args) {

        //Set<Book> ss = new HashSet<>();
        //ss.add(new Book(10,"《java》"));
        //ss.add(new Book(11,"《php》"));
        //ss.add(new Book(12,"《python》"));
        //ss.add(new Book(13,"《mysql》"));
        //System.out.println(ss.size());
        //System.out.println(ss);

        Set<Integer> ss = new HashSet<>();
        Random rand = new Random();
        while (ss.size() < 6) {
            ss.add(rand.nextInt(1, 33));
        }
        System.out.println(ss.size());
        System.out.println(ss);
        System.out.println(ss);

        //将Set转换为List,使用Collections.sort()排序
        List<Integer> nn = new ArrayList<>(ss);
        Collections.sort(nn);
        System.out.println(nn);

        //List<String> sss;
        //Set<String> cites;

    }
}
